package com.atguigu.tingshu.order.interceptor.impl;

import com.alibaba.fastjson.JSON;
import com.atguigu.tingshu.common.constant.SystemConstant;
import com.atguigu.tingshu.order.helper.SignHelper;
import com.atguigu.tingshu.order.interceptor.OrderHandlerInterceptor;
import com.atguigu.tingshu.vo.order.OrderInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
@Slf4j
public class ValidDataOrderHandlerInterceptor implements OrderHandlerInterceptor {
    @Override
    public OrderInfoVo sbumitOrderRequestProcess(OrderInfoVo orderInfoVo) {
        Map<String,Object> map = JSON.parseObject(JSON.toJSONString(orderInfoVo), Map.class);
        map.put("payWay", SystemConstant.ORDER_PAY_WAY_WEIXIN);
        SignHelper.checkSign(map);
        log.info("{}数据合法性校验通过了。。。",JSON.toJSONString(orderInfoVo));
        return orderInfoVo;
    }

    @Override
    public int sort() {
        return 1;
    }
}
